import Axios from 'axios'
import Vue from 'vue'

let instance = Axios.create({
    baseURL:'https://www.fastmock.site/mock/808be44151992ba0b9980b83ed609de7/kaishanqunawang',
    timeout:1000
})

instance.interceptors.request.use(
    config =>{
        if(sessionStorage.getItem('token')){
            config.headers.Authorizetion = sessionStorage.getItem('token')
        }
        return config
    },
    error =>{
        return Promise.reject(error)
    }
    
    )

instance.interceptors.response.use(
    
    res => {
        console.log(res)
        if(res.data.code == 200){
            return Promise.resolve(res)
        }
    },
    error => {
      return Promise.reject(error)
    }
)

export default instance